package com.dctp.common.db;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class ContractDb {
    public static Record findById(Long contractId) {
        return Db.findFirst("SELECT * FROM dctp_contract WHERE id = ?", contractId);
    }
    public static void update(Long contractId, Record contract) {
        Db.update("dctp_contract", "id", contract);
    }
    public static void delete(Long contractId) {
        Db.update("DELETE FROM dctp_contract WHERE id = ?", contractId);
    }
    public static Record findBySymbol(String symbol) {
        return Db.findFirst("SELECT * FROM dctp_contract WHERE symbol = ? and status = 1 limit 1 ", symbol);
    }

    public static List<Record> findAll() {
        return Db.find("SELECT id,symbol FROM dctp_contract where status = 1 ");
    }
}
